package main

import (
	"fmt"
	"time"
)



func job(index int) int{

	time.Sleep(time.Millisecond*500)
	return index

}

func main(){

	start:=time.Now()
	num:=5

	retCh :=make(chan int) //结果chan

	for i:=0;i<num;i++{
		go func(param int){
			retCh <-job(param)
		}(i)

	}

	count:=0

	for item:=range retCh{
		count++
		fmt.Println("收到结果",item)


		if count==num{
			close(retCh)
			break
		}
	}



	end:=time.Since(start)
	fmt.Println("耗时",end.String())

}


//耗时 524.1048ms
